package com.lantu.image;

import java.io.File;
import java.io.IOException;

import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;

/**
 * 图片裁剪api
 * @author wanghao
 *
 */
public class ImageCutUtil {
	public static void main(String[] args) {
		String imgFile = "C:\\Users\\wanghao\\Desktop\\testing-images\\2043d07892fc42f2350bebb36c4b72ce1409212020.jpg";// 待处理的图片
		ImageCutUtil.cut(imgFile);
	}
	public  static  void cut(String filename){
		try {
			Thumbnails.of(new File(filename))
			//.sourceRegion(Positions.CENTER,100,100)
			.sourceRegion(50,0,200,200)
			.size(200, 200)
			.toFile(new File("C:\\Users\\wanghao\\Desktop\\testing-images\\thumbnail.jpg"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
